// src/utils/request.js
const BASE_URL = 'http://localhost:9000'

// 覆盖原始 uni.request 方法
uni.$originalRequest = uni.request

uni.request = function (options) {
  const token = uni.getStorageSync('token') || ''
  const fullUrl = options.url.startsWith('http') ? options.url : BASE_URL + options.url

  return uni.$originalRequest({
    ...options,
    url: fullUrl,
    header: {
      token,
      'content-type': 'application/x-www-form-urlencoded',
      ...(options.header || {})
    }
  })
}
